New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asset_path
respects SCRIPT_NAME.
#9646
Conversation
@steveklabnik @guilleiguaran can you take a look? |
@@ -133,6 +133,8 @@ def asset_path(source, options = {}) | |||
end | |||
|
|||
relative_url_root = defined?(config.relative_url_root) && config.relative_url_root | |||
request = self.request if respond_to?(:request) | |||
relative_url_root ||= request.script_name if request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if respond_to?(:request)
should be enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw this pattern down below: https://github.com/senny/rails/blob/83613ca60b1d536003a58839cd878a0fd8673be3/actionpack/lib/action_view/helpers/asset_url_helper.rb#L195
I'm not sure the request
method can actually return nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it returns nil for ActionMailer, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we should keep it the way it is then. If this PR makes it in, I'd like to perform a quick cleanup/refactoring on the that helper code.
I am afraid this will cause unintended side effects. If you have a mountable engine, the script_name will also be set but in this case, asset_path still should not consider script path because the entity responsible for delivering assets is in the main application (sprockets in this case). So I think we should create a mountable engine and ensure we can still access its assets after this patch. Things can get even trickier, because you have can have a mountable engine with Passenger's script_name and in this case we should use only the one coming from passenger. Here are a couple places to look at:
|
As far as I can tell AC still has a |
@senny you're meant to set I think we need to have a CF chat about the various options and come up with a plan for sorting this out. |
@pixeltrix thanks for clarifying. I put my work on hold and catch you on CF. |
I'm closing this one as this is not a viable solution. I'm working on a different approach. |
Closes #2992
The code on
3-2-stable
is very different but It should be an easy fix too.